package com.itheima.pojo;

import com.alibaba.fastjson.annotation.JSONField;
import com.alibaba.fastjson.serializer.SerializerFeature;
import lombok.Data;

import java.util.Date;

/**
 * @author 陆小根
 * date: 2022/06/23
 * Description:
 */

@Data
public class Student {
  public Student() {
  }

  public Student(Integer id, String name, Integer age, String email, Date birthday) {
    this.id = id;
    this.name = name;
    this.age = age;
    this.email = email;
    this.birthday = birthday;
  }

  private Integer id;

  /**
   * @JSONField
   *  - name属性：执行序列化后的名字
   *  - ordinal属性：指定序列化后的字段的顺序 属性值越小，顺序越靠前
   */
  @JSONField(name = "studentName", ordinal = 1)
  private String name;
  @JSONField(ordinal = 2, serialzeFeatures = {SerializerFeature.WriteNullNumberAsZero})
  private Integer age;

  /**
   * 注解属性 serialize 指定是否序列化该字段
   */
  @JSONField(serialize = false)
  private String email;
  /**
   * format：指定序列化后的格式
   */
  @JSONField(format = "YYYY/MM/dd")
  private Date birthday;
  private Boolean flag;

}
